#define _CRT_SECURE_NO_WARNINGS
#include<iostream>

using namespace std;

int main()
{
	int count = 0;
	int x, y, r, min_mul, max_div, x1, y1;
	cin >> count;
	while (count)
	{
		cin >> x >> y;
		x1 = x, y1 = y;
		r = x1 % y1;
		while (r)
		{
			x1 = y1;
			y1 = r;
			r = x1 % y1;
		}
		min_mul = y1;
		max_div = x * y / min_mul;
		cout << min_mul << ' ' << max_div << endl;
		count--;
	}


	return 0;
}